def isAnagram(str1, str2):
    char_count ={}
    for char in str1:
        if char in char_count:
            char_count[char]+=1
        else:
            char_count[char]=1
    for char in str2:
        if char in char_count:
            char_count[char]-= 1
        else:
           return False
    for count in char_count.values():
        if count != 0:
            return False
    return True
def main():
    s1 =input()
    s2 =input()
    print(1 if isAnagram(s1,s2)else 0)
if __name__ == '__main__':
    main()
# === DO NOT modify the code above ===